package greedy;

import java.util.HashMap;
import java.util.Map;

/**
 * @ Author     ：侯耀祖
 * @ Description：
 */
public class lemonadeChange {
    public boolean lemonadeChange(int[] bills) {
        int five = 0, ten = 0, twenty = 0;
        for (int bill : bills) {
            if (bill == 5){
                five++;
            }
            if (bill == 10){
                if (five <= 0){
                    return false;
                }
                ten++;
                five--;
            }
            if (bill == 20){
                if (five > 0 && ten > 0){
                    five--;
                    ten--;
                } else if (five >= 3){
                    five -= 3;
                } else {
                    return false;
                }
            }
        }
        return true;
    }
}
